package com.running.base.run.enums;

/**
 * 审计日志用户枚举
 */
public enum AuditUserEnum {
    
    ADMIN("admin", "管理员"),
    OPERATOR("operator", "运维员"),
    USER("user", "普通用户");
    
    private final String username;
    private final String description;
    
    AuditUserEnum(String username, String description) {
        this.username = username;
        this.description = description;
    }
    
    public String getUsername() {
        return username;
    }
    
    public String getDescription() {
        return description;
    }
    
    /**
     * 根据用户名获取枚举
     * @param username 用户名
     * @return 对应的枚举值，未找到则返回null
     */
    public static AuditUserEnum fromUsername(String username) {
        for (AuditUserEnum enumValue : AuditUserEnum.values()) {
            if (enumValue.getUsername().equals(username)) {
                return enumValue;
            }
        }
        return null;
    }
}